package com.hxl.aop.controller;

import com.hxl.aop.entity.SysUser;
import com.hxl.aop.res.AjaxResult;
import com.hxl.aop.res.annotation.Log;
import com.hxl.aop.res.enums.BusinessType;
import com.hxl.aop.res.enums.OperatorType;
import com.hxl.aop.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 动态数据源控制层
 *
 * @author 霍帅帅
 * @since 2024-07-23 22:04
 */
@RestController
@RequestMapping("/dynamic")
public class DynamicDataSourceController {

    @Autowired
    private UserService userService;

    /**
     * 查询用户列表
     * @param sysUser
     * @return
     */
    @PostMapping("/list")
    public AjaxResult list(@RequestBody SysUser sysUser){
        return AjaxResult.success("查询用户列表成功",userService.list(sysUser));
    }

    @PostMapping("/listS")
    @Log(businessType = BusinessType.SELECT,title = "slave数据源切换查询测试",operatorType = OperatorType.MANAGE)
    public AjaxResult listS(@RequestBody SysUser sysUser){
        return AjaxResult.success("查询用户列表成功_SLAVE",userService.listS(sysUser));
    }
}
